<?php
/*
+--------------------------------------------------------------------------
|   phpBIZbiz v3.0 full version
|   ========================================
|   by taft@wjl.cn
|   http://www.phpbiz.cn
|   all rights reserved
+---------------------------------------------------------------------------
|
|   > 
|   > 最后修改日期：2005-9-9
|   > 
|
+--------------------------------------------------------------------------
*/
!function_exists('do_login') && exit('Forbidden');
$op = new operation;
class operation
{
	var $gdt;
	
	function operation()
	{
		global $INCOME,$ADMIN,$ADMINER;

		$this -> gdt = array( 0 => array( 0, '0：禁止所有功能' ),
							 1 => array( 1, '1：普通管理员' ),
							 2 => array(2,'2：中级管理员'),
							 3 => array( 3, '3：根管理员')
						   );
		//---------------------------------------
		// Kill globals - globals bad, Homer good.
		//---------------------------------------
		
		$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
		
		foreach ( $tmp_in as $k => $v )
		{
			unset($$k);
		}

		switch($INCOME['code'])
		{
			case 'doop':
				$this->save_config( array ( 'biz_name',
											'biz_url',
											'debug_level',
											'upload_base_dir',
											'smarty_cache',
											'cache_time',
											'smarty_cache_time',
											'smarty_debug',
											'bakup_dir',
											'check_seller',
											'check_shop',
											'domain',
											'reg_agreement',
											'reg_open',
											'att_size',
											'att_type',
											'session_expiration',
											'single_upload_dir',
											'service_telephone',
											'beianCode',
											'hotsearch' ) );
				break;
			case 'reset':
				$this->reset_form();
				break;
			case 'doreset':
				$this->do_reset();
			    break;
			case 'right':
				$this->right_form();
			    break;
			case 'doright':
				$this->do_right();
			    break;
			case 'rightset':
				$this -> rightset_rank();
			    break;
			case 'setform':
				$this -> rightset_form();
			    break;
			case'dorightset':
				$this -> do_rightset();
			    break;
			case 'addop':
				$this-> add_op();
			    break;
			case 'onlinepay':
				$this -> onlinepay();
			    break;
			case 'doonlinepay':
				$this -> doonlinepay();
			    break;
			default:
				$this -> op_form();
			    break;
		}
		//---------------------------------------
	}

	function op_form()
	{
		global $ADMIN,$INCOME,$SKIN,$CONF,$DB;
		
		$dbconf =array();
		foreach( array('reg','att') as $vv)
		{
			$DB -> db_query("SELECT * FROM `biz_global_configure` WHERE `key` LIKE '%{$vv}%' ");
			while($r=$DB -> db_fetch_row())
			{
				$k = $r['key'];$v = $r['value'];
				$dbconf[$k] = $v;
			}
		}

		$ADMIN -> page_title = "基本设定";
		$ADMIN -> page_instruction ="这里包含了phpBIZ的基本设定，在变更前请仔细阅读项目说明。";
		
		$SKIN->td_header[] = array( ""  , "40%" );
		$SKIN->td_header[] = array( ""  , "60%" );

		$ADMIN->html .= $SKIN->table_head( "BIZ基本设定选项" );

		$ADMIN->html .= $SKIN->form_head();
		$ADMIN->html .= $SKIN->form_input("code","doop","hidden");
        $ADMIN->html .= $SKIN->form_input("act","op","hidden");

        //+----------------------------------------------------------

        $ADMIN->html .= $SKIN->td_basic( 'BIZ名称和HTTP地址', 'left', 'catrow2' );
		$ADMIN->html .= $SKIN->table_row( array( "<b>BIZ名称</b>" ,
										  $SKIN->form_input( "biz_name", $CONF['biz_name']  )
								 )      );
		$ADMIN->html .= $SKIN->table_row( array("<b>BIZ地址</b>" ,
										  $SKIN->form_input( "biz_url", $CONF['biz_url']  )
								 )      ); 
		$ADMIN->html .= $SKIN->table_row( array("<b>网站域名</b><br>注意：用于二级域名，请按照 biz.wjl.cn 格式写" , $SKIN->form_input( "domain", $CONF['domain']  )
								 )      ); 
		$ADMIN->html .= $SKIN->table_row( array("<b>数据库备份路径</b><br>注意：这是路径而不是URL" ,
										  $SKIN->form_input( "bakup_dir", $CONF['bakup_dir']  )
								 )      ); 
		
		$ADMIN->html .= $SKIN->table_row( array("<b>是否开启商家审查?</b>" ,
										   $SKIN->form_yes_no( "check_seller", $CONF['check_seller'] )  )
								 ); 
		$ADMIN->html .= $SKIN->table_row( array("<b>是否开启店铺审查?</b>" ,
										   $SKIN->form_yes_no( "check_shop", $CONF['check_shop'] )  )
								 ); 		 
        //+-----------------------------------------------------------------------
		$ADMIN->html .= $SKIN->td_basic( '调试', 'left', 'catrow2' );
		$ADMIN->html .= $SKIN->table_row( array("<b>调试级别</b>" ,
										  $SKIN->form_droplist( "debug_level", 
										  						 array(
										  						 		0 => array( 0, '0：无-不显示任何调试信息' ),
										  						 		1 => array( 1, '1：显示服务器加载、页面产生时间和查询次数' ),
										  						 		2 => array( 2, '2：显示级别1（上述）和GET和POST信息'),
										  						 		3 => array( 3, '3：显示级别1+2和数据库查询语句'),
										  						 	  ),
										 						 $CONF['debug_level']   )								 )      );
		$ADMIN->html .= $SKIN->table_row( array("<b>是否开启Samrty调试窗口?</b>" ,
										   $SKIN->form_yes_no( "smarty_debug", $CONF['smarty_debug'] )  )
								 ); 
        //+-----------------------------------------------------------------------
		$ADMIN->html .= $SKIN->td_basic( 'Smarty选项', 'left', 'catrow2' );
		$ADMIN->html .= $SKIN->table_row( array("<b>是否开启页面CACHE?</b>" ,
										   $SKIN->form_yes_no( "smarty_cache", $CONF['smarty_cache'] )  )
								 ); 
		$ADMIN->html .= $SKIN->table_row( array("<b>页面缓存时间（秒）</b><br>注意：只有开启页面CACHE才有效" ,
										  $SKIN->form_input( "smarty_cache_time", $CONF['smarty_cache_time']  )
								 )      );
		//+-----------------------------------------------------------------------
	    $ADMIN->html .= $SKIN->td_basic( '注册选项','left', 'catrow2');
		$ADMIN->html .= $SKIN->table_row( array('<b>是否允许新用户注册</b>',$SKIN->form_yes_no( "reg_open", $dbconf['reg_open'] )) );
		$ADMIN->html .= $SKIN->table_row( array('<b>在这里输入注册协定</b>',"<TEXTAREA NAME='reg_agreement' ROWS='10' COLS='50'>".$dbconf['reg_agreement']."</TEXTAREA>" ) );        
        //+----------------------------------------------------------------------
        $ADMIN->html .= $SKIN->td_basic( '图片上传选项','left', 'catrow2');
		$ADMIN->html .= $SKIN->table_row( array('<b>上传附件大小上限(k)</b>',"<INPUT TYPE='text' NAME='att_size' size='6' value='{$dbconf[att_size]}'> (K)" ) );
		$ADMIN->html .= $SKIN->table_row( array("<b>是否单一目录保存图片</b><br>如果您的服务器safe_mode开启，请选择是。否则照片按照日期分类保存。一次设定后请不要再次更改。",$SKIN->form_yes_no("single_upload_dir",$CONF['single_upload_dir'])
								)		);
		$ADMIN->html .= $SKIN->table_row( array("<b>图片上传基路径</b><br>注意：这是路径而不是URL" ,
										  $SKIN->form_input( "upload_base_dir", $CONF['upload_base_dir']  )
								 )      ); 
		$ADMIN->html .= $SKIN->table_row( array("<b>上传图片允许后缀(以'|'隔开)</b><br>" ,
										  $SKIN->form_input( "att_type", $dbconf[att_type] )
								 )      ); 
		//+----------------------------------------------------------------------
        $ADMIN->html .= $SKIN->td_basic( '杂项','left', 'catrow2');
		$ADMIN->html .= $SKIN->table_row( array("<b>热门搜索(以'|'隔开)</b><br>",$SKIN->form_input( "hotsearch", $CONF['hotsearch'] ) ) );
		$ADMIN->html .= $SKIN->table_row( array("<b>统计时长（秒）</b>",$SKIN->form_input("session_expiration",$CONF['session_expiration']) ) );
		$ADMIN->html .= $SKIN->table_row( array("<b>服务热线 </b><br>客服电话，便于冲点咨询和其他客服。",$SKIN->form_input("service_telephone",$CONF['service_telephone']) ) );
		$ADMIN->html .= $SKIN->table_row( array("<b>网站备案号 </b><br>http://www.miibeian.gov.cn/",$SKIN->form_input("beianCode",$CONF['beianCode']) ) );
		$ADMIN->html .= $SKIN ->form_end("提交修改");
		$ADMIN->html .= $SKIN ->table_end();

		$ADMIN->output();
	}

	function reset_form()
	{
		global $DB,$ADMIN,$SKIN;

		$DB-> db_query( "SELECT last_time as lt FROM biz_global_configure " );
	
	    $r = $DB -> db_fetch_row();

		$time_string = date( "Y-m-d H:i:s", $r['lt'] );

		$ADMIN -> page_title ="恢复配置";
		$ADMIN -> page_instruction ="如果conf_global.php文件不小心被手动修改，请使用该功能恢复上一次自动设置。";

		$ADMIN -> html .= $SKIN -> table_head();
		$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input( "code","doreset","hidden");

		$ADMIN -> html .= $SKIN -> td_basic("上一次配置保存时间是：<b>{$time_string}</b>","center");
		$ADMIN -> html .= $SKIN -> form_end("恢复");
		$ADMIN -> html .= $SKIN -> table_end();
		
		$ADMIN -> output();
	}

	function right_form()
	{
		global $DB,$ADMIN,$SKIN;
        
		$DB -> db_query( "SELECT * FROM biz_admin_user" );

		$SKIN -> td_header[] = array( "管理员帐号","25%" );
		$SKIN -> td_header[] = array( "权限组别","8%" );
		$SKIN -> td_header[] = array( "登陆次数","15%" );
		$SKIN -> td_header[] = array( "上次访问时间","25%" );
		$SKIN -> td_header[] = array( "上次访问IP","" );
		$SKIN -> td_header[] = array( "打钩删除","");
        
		$ADMIN -> page_title="后台管理员权限管理";
		$ADMIN -> page_instruction = "这里可以添加，修改或删除管理员，请勿把创始管理员的级别降低，以免给管理带来不便。";

		$ADMIN -> html .= $SKIN -> table_head("管理员列表");
		$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input("code","doright","hidden");
		while( $ad_r = $DB -> db_fetch_row() )
		{
				$ADMIN->html .= $SKIN->table_row( array("<b>{$ad_r[user_account]}</b>",
										  $SKIN->form_droplist( "user_level_{$ad_r['user_id']}", 
										  						 $this -> gdt,
										 						 $ad_r['user_level']   ),"{$ad_r['user_visit_count']}","{$ad_r['user_last_visit_date']}","{$ad_r['user_ip']}","<center>".$SKIN->form_input("delid[]",$ad_r['user_id'],"checkbox")."</center>" ) );
		}

		$ADMIN -> html .= $SKIN -> form_end("修改");
		$ADMIN -> html .= $SKIN -> table_end();
		$ADMIN -> html .= $SKIN -> td_spacer();	
        //-----------------------------------------------------------
		//add operators
		//-----------------------------------------------------------]
		$SKIN -> td_header[] = array(" ","20%");
		$SKIN -> td_header[] = array(" ","50%");
		$ADMIN -> html .= $SKIN -> table_head("添加管理员");
		$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input("code","addop","hidden");
		$ADMIN -> html .= $SKIN -> table_row( array("管理员帐号",$SKIN -> form_input("account") ) );
		$ADMIN -> html .= $SKIN -> table_row( array("管理员密码",$SKIN -> form_input("passy","","password") ) );
		$ADMIN -> html .= $SKIN -> table_row( array("管理员密码重复",$SKIN -> form_input("repassy","","password") ) );
		$ADMIN -> html .= $SKIN -> table_row( array("权限组别",$SKIN -> form_droplist("level",$this -> gdt,'0')));
		$ADMIN -> html .= $SKIN -> form_end(" 增 加 ");
		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> output();
	}

	function add_op()
	{
		global $DB,$ADMIN,$INCOME;

		foreach( array("account","passy","repassy") as $v)
		{
			if(!$INCOME[$v]) $ADMIN -> error("添加表单不完整，请返回重填。");
		}

		$DB -> db_query("SELECT * FROM biz_admin_user WHERE user_account='".$INCOME['account']."'");
		if( $DB -> db_fetch_num() ) $ADMIN -> error("该管理员帐号已注册，请返回重填。");
		
		if( $INCOME['passy']!= $INCOME['repassy'] )
			$ADMIN -> error("两次密码不一致，请返回重填。");


		$db_string = $DB -> db_compile_fields( array("user_account" => $INCOME['account'],
			                                         "user_password" => md5($INCOME['passy']),
			                                         "user_level" => $INCOME['level']  ) );
		$DB->db_query("INSERT INTO biz_admin_user (".$db_string['fields'].") VALUES (".$db_string['value'].")");

		$ADMIN->record_log("添加新管理员‘{$INCOME[account]}’");
		$ADMIN->done_screen("权限管理修改成功", "权限管理", "act=op&code=right" );

	}


	function do_right()
	{
		global $INCOME,$DB,$ADMIN;

		$res = $DB -> db_query( "SELECT user_id FROM biz_admin_user " );
	    $id_data = @implode(",",$INCOME[delid]);
		if(count($INCOME[delid]))
		{
			$DB -> db_query("DELETE FROM biz_admin_user WHERE user_id IN (".$id_data.")");
			$str_log =", 并且删除了管理员帐号。";
		}

		while( $r = $DB -> db_fetch_row( $res ) )   //遍历
		{
			$level_str = "user_level_".$r['user_id'];
		    $level = intval( $INCOME[$level_str] );

			$DB -> db_query( " UPDATE `biz_admin_user` SET `user_level` = '$level' WHERE `user_id` ='".$r['user_id'] ."' LIMIT 1 ");
		}
        
		$ADMIN->record_log("修改管理员权限".$str_log);
		
		$ADMIN->done_screen("权限管理修改成功", "权限管理", "act=op&code=right" );

	}

	function rightset_rank()
	{
		global $ADMIN,$SKIN;

		$ADMIN -> page_title ="权限组别列表";
		$ADMIN -> page_instruction ="选择您要修改的组别，然后进行每个操作的权限设定";
		$ADMIN -> html = $SKIN -> table_head("权限组别列表");
		$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input("code","setform","hidden");

		foreach( $this->gdt as $k => $v)
		{
			if($k) $ADMIN -> html .= $SKIN -> td_basic("<center>$v[1]</center><br><center>".$SKIN->form_input("submit[$v[0]]"," 修 改 ","submit")."</center>");
		}
		$ADMIN -> html .= "</form>";
		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> output();
	}

	function rightset_form()
	{
		global $DB,$ADMIN,$SKIN,$CATS,$TREE,$INCOME;
        
		foreach( $INCOME['submit'] as $k => $v) $gid = intval($k);

		$DB -> db_query("SELECT rightset FROM biz_admin_level WHERE gid=".$gid);
		$r = $DB -> db_fetch_row();
		$right=unserialize($r['rightset']);
		
		$ADMIN -> page_title ="编辑组权限";
		$ADMIN -> page_instruction ="‘是’为允许，‘否’为禁止";
		$SKIN -> td_header[] = array(" ","40%"); 
		$SKIN -> td_header[] = array(" ",""); 
		$ADMIN -> html = $SKIN ->table_head();
		$ADMIN -> html .=$SKIN -> form_head();
		$ADMIN -> html .=$SKIN -> form_input("code","dorightset","hidden");
        $ADMIN -> html .=$SKIN -> form_input("gid",$gid,"hidden");

		foreach( $CATS as $k => $v)
		{
			$ADMIN -> html .= $SKIN -> td_basic("<b>$v</b>");
			foreach($TREE[$k] as $kk => $vv )
			$ADMIN -> html .= $SKIN -> table_row( array("<div align=right><a href='admin.php?$vv[1]'>$vv[0]</a></div> ",$SKIN->form_yes_no("rightdb[$kk]",$right[$kk])) );
		}
		$ADMIN -> html .= $SKIN -> form_end();
		$ADMIN -> html .= $SKIN -> table_end();
		$ADMIN -> output();
	}

	function do_rightset()
	{
		global $DB,$INCOME,$ADMIN,$HIDDEN;
        $gid = intval($INCOME[gid]);
		$rightdb = $INCOME[rightdb];
		if(!count($rightdb)) $ADMIN -> error("参数丢失");
		foreach( $rightdb as $k => $v)
		{
			if($rightdb[$k])
			{ 
			   if(is_array($HIDDEN[$k])) 
				   foreach($HIDDEN[$k] as $kk => $vv)
			          $rightdb[$vv] = 1;
			}
		}
		$into = serialize($rightdb);
		$DB -> db_query("REPLACE INTO biz_admin_level (gid,rightset) VALUES('$gid','$into')");
        $ADMIN->done_screen("权限组修改成功", "权限组修改", "act=op&code=rightset" );

	}

    function do_reset()
	{
		global $DB,$ADMIN,$std;

		$new = array();

		$DB -> db_query( "SELECT `key` as k, `value` as v FROM biz_global_configure " );
         
		if( $DB->db_fetch_num() )
		{
			while( $r = $DB->db_fetch_row() )
			{
				$k = $r['k'];
				$v = $r['v'];
			    $new[$k] =$v;
			}
			$std -> rebuild_config($new);
		}

		$ADMIN->record_log("BIZ设定恢复，写回configure.php");
		
		$ADMIN->done_screen("BIZ配置恢复成功", "BIZ配置恢复", "act=reset" );
	}

	//-------------------------------------------------------------
	//
	// Save config. Does the hard work, so you don't have to.
	//
	//--------------------------------------------------------------
	
	function save_config( $new )
	{
		global $CONF, $DB, $SKIN, $ADMIN, $_POST,$std;
		
		$master = array();
		
		if ( is_array($new) )
		{
			if ( count($new) > 0 )
			{
				foreach( $new as $field )
				{
				
					// Handle special..
					
					if ( $field == 'html_dir' OR $field == 'upload_base_dir')
					{
						$_POST[ $field ] = preg_replace( "/'/", "&#39;", $_POST[ $field ] );
					}
					else
					{
						$_POST[ $field ] = preg_replace( "/'/", "&#39;", stripslashes($_POST[ $field ]) );
					}
				
					$master[ $field ] = addslashes($_POST[ $field ]);
				}
				
				$std -> rebuild_config($master);
			}
		}
		//clear cache 
		@unlink(ROOT_PATH.'cache/reg_cache.php');
		@unlink(ROOT_PATH.'cache/upload_cache.php');
		
		$ADMIN->record_log("phpBIZ设定更新，写回configure.php");
		$ADMIN->done_screen("phpBIZ配置更新成功", "BIZ配置更新", "act=op&code=basic" );
					
	}

	function onlinepay()
	{
		global $DB,$SKIN,$ADMIN,$CONF;

		$DB -> db_query("SELECT value FROM biz_global_configure  WHERE `key` ='account_info'");
		$rs = $DB -> db_fetch_row();
		$account_data = unserialize($rs['value']);

		$ADMIN -> page_title="在线支付设置";
		$ADMIN -> page_instruction="使用网上支付相关说明：<br>1. 开启网上支付功能即被视为接受“phpBIZ”相关协议，如有任何疑义,请关闭此功能<br>
		2. 支付过程出现问题请及时和 phpBIZ 官方取得联系<br>
		3. 因使用网站自身安全原因引起的非法支付phpBIZ 不负任何责任";

		/*  alipay*/
		$SKIN ->td_header[] = array("","100%");
		$ADMIN -> html = $SKIN -> table_head("开通支付宝支付步骤");
		$ADMIN -> html .= $SKIN -> table_row( array("1. <a href='https://www.alipay.com/user/user_register.htm' target='_blank'>注册一个支付宝帐号</a><br>
			2. 获取支付宝帐户信息并设置交易即时付款通知<br>
				 &nbsp; &nbsp;登录支付宝网站：进入 支付宝->商家工具->设置安全校验码 根据提示获取您的安全校验码
				 并设置 <font color='red'>通知接受URL</font>: 您的商城地址 &nbsp;&nbsp;(".$CONF[biz_url].") + 'alipay_notify.php'
				 &nbsp; &nbsp;格式如：<font color='red'>".$CONF[biz_url]."alipay_notify.php</font><br>
			3. 将支付宝信息填写到商城用户后台<br>
				 &nbsp; &nbsp;进入商城用户后台 -> 在线支付设置 -> 支付宝信息 将您的支付宝帐号填写在 \"账号\" 栏
			 &nbsp; &nbsp;<br> &nbsp; &nbsp;并且设置密钥,此密钥从支付宝网站上获取<br>
			4. 完成以上步骤后即可开始使用phpBIZ支付宝网上支付功能<br><br>
			 &nbsp; &nbsp;注: 保证此密钥与您在支付宝网站获得的安全校验码相同 ") );
			$ADMIN -> html .= $SKIN -> table_end();

			$ADMIN -> html .= $SKIN -> td_spacer();	
			$SKIN ->td_header[] = array("","30%");
			$SKIN ->td_header[] = array("","70%");
			
		    $ADMIN -> html .= $SKIN -> table_head("支付宝信息");
			$ADMIN -> html .= $SKIN -> form_head();
			$ADMIN -> html .= $SKIN -> form_input("code","doonlinepay","hidden");
			$ADMIN -> html .= $SKIN -> form_input("type","alipay","hidden");
            $ADMIN -> html .= $SKIN -> table_row(array("是否使用alipay：",$SKIN->form_yes_no( "enable_alipay",$account_data['alipay'][0]) ));
			$ADMIN -> html .= $SKIN -> table_row(array("账号：",$SKIN->form_input("alipay_account",$account_data['alipay'][1])));
			$ADMIN -> html .= $SKIN -> table_row(array("密钥：",$SKIN->form_input("alipay_key",$account_data['alipay'][2])));
			$ADMIN -> html .= $SKIN -> form_end();
			$ADMIN -> html .= $SKIN -> table_end();
		/* alipay end */

		/* cncard */
		$ADMIN -> html .= $SKIN -> td_spacer();
		$SKIN ->td_header[] = array("","100%");
		$ADMIN -> html .= $SKIN -> table_head("开通云网支付步骤");
		$ADMIN -> html .= $SKIN -> table_row( array("1. <a href='http://www.cncard.net/products/products.asp' target='_ blank'>注册一个云网帐号</a><br>2. 设置通知URL <br>3. 将云网信息填写到商城用户后台<br>&nbsp; &nbsp;进入商城用户后台 -> 在线支付设置 -> 云网信息 将您的云网帐号填写在 \"账号\" 栏
			 &nbsp; &nbsp;<br> &nbsp; &nbsp;并且设置密钥,此密钥从云网网站上获取<br> 4. 完成以上步骤后即可开始使用phpBIZ云网网上支付功能<br><br>&nbsp; &nbsp;注: 保证此密钥与您在云网获得的安全校验码相同") );
		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> html .= $SKIN -> td_spacer();
		$SKIN ->td_header[] = array("","30%");
		$SKIN ->td_header[] = array("","70%");
		$ADMIN -> html .= $SKIN -> table_head("云网信息");
		$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input("code","doonlinepay","hidden");
		$ADMIN -> html .= $SKIN -> form_input("type","cncard","hidden");
        $ADMIN -> html .= $SKIN -> table_row(array("是否使用云网：",$SKIN->form_yes_no( "enable_cncard",$account_data['cncard'][0]) ));
		$ADMIN -> html .= $SKIN -> table_row(array("账号：",$SKIN->form_input("cncard_account",$account_data['cncard'][1])));
		$ADMIN -> html .= $SKIN -> table_row(array("密钥：",$SKIN->form_input("cncard_key",$account_data['cncard'][2])));
		$ADMIN -> html .= $SKIN -> form_end();
		$ADMIN -> html .= $SKIN -> table_end();
		/* cncard end*/

		/* bill */
			$ADMIN -> html .= $SKIN -> td_spacer();	
			$SKIN ->td_header[] = array("","100%");
			$ADMIN -> html .= $SKIN -> table_head("开通快钱支付步骤");
			$ADMIN -> html .= $SKIN -> table_row(array("1. <a href='https://www.99bill.com/webapp/jsp/AccountManage/accountRegAction.do?cmd=initializtion' target='_blank'>注册一个快钱帐号</a><br>
			2. 获取快钱帐户信息<br>
			 &nbsp; &nbsp;登录快钱网站：进入 我的快钱 -> 支付网关 获取您的商户号并根据提示 设置您的快钱密钥<br>
			3. 将快钱信息填写到商城用户后台<br>
			  &nbsp; &nbsp;进入商城用户后台 -> 在线支付设置 -> 快钱信息 将您的快钱商户号填写在 \"商户编号\" 栏<br>
			  &nbsp; &nbsp;并且设置快钱密钥<br>
			4. 完成以上步骤后即可开始使用phpBIZ 快钱网上支付功能<br><br>
			注: 保证此密钥与您在快钱网站的设置相同<br>
			 &nbsp; &nbsp; 由您通过快钱支付产生的相应费用请以快钱网站为准"));
			 $ADMIN -> html .= $SKIN -> table_end();

			 $ADMIN -> html .= $SKIN -> td_spacer();
			 $SKIN ->td_header[] = array("","30%");
			 $SKIN ->td_header[] = array("","70%");
			 $ADMIN -> html .= $SKIN -> table_head("快钱信息");
			 $ADMIN -> html .= $SKIN -> form_head();
			 $ADMIN -> html .= $SKIN -> form_input("code","doonlinepay","hidden");
			 $ADMIN -> html .= $SKIN -> form_input("type","bill","hidden");
			 $ADMIN -> html .= $SKIN -> table_row(array("是否使用快钱",$SKIN->form_yes_no("enable_bill",$account_data['bill'][0])));
			 $ADMIN -> html .= $SKIN -> table_row(array("账号：",$SKIN->form_input("bill_account",$account_data['bill'][1])));
			 $ADMIN -> html .= $SKIN -> table_row(array("密钥：",$SKIN->form_input("bill_key",$account_data['bill'][2])));
			 $ADMIN -> html .= $SKIN -> form_end();
			 $ADMIN -> html .= $SKIN -> table_end();
		/* bill end */

		$ADMIN -> output();
	}

	function doonlinepay()
	{
		global $DB,$SKIN,$ADMIN,$CONF,$INCOME;

		$DB -> db_query("SELECT value FROM biz_global_configure  WHERE `key` ='account_info'");
		$rs = $DB -> db_fetch_row();
		$account_data = unserialize($rs['value']);

		$type = $INCOME['type'];
		$key1="enable_".$type;
		$key2=$type."_account";
		$key3=$type."_key";
		$account_data[$type] = array($INCOME[$key1],$INCOME[$key2],$INCOME[$key3]);

		$account_data = serialize($account_data);
		$DB -> db_query("REPLACE INTO `biz_global_configure`  (`key`,`value`) VALUES ('account_info','$account_data')");
	
		$ADMIN->record_log("配置在线支付帐号");
		$ADMIN->done_screen("phpBIZ在线支付帐号配置成功", "phpBIZ在线支付帐配置", "act=op&code=onlinepay" );
			
	}
}
?>